home *** CD-ROM | disk | FTP | other *** search
- Path: news.infi.net!usenet
- From: nngis@norfolk.infi.net (Greg DiGiorgio)
- Newsgroups: comp.lang.c
- Subject: Re: How to search files for a string?
- Date: 30 Jan 1996 13:02:16 GMT
- Organization: Customer of InfiNet
- Message-ID: <4el4so$glk@nw002.infi.net>
- References: <4ek1qb$11m0@pulp.ucs.ualberta.ca>
- Reply-To: nngis@norfolk.infi.net
- NNTP-Posting-Host: h-geraldsgame.norfolk.infi.net
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.99.3
-
- In article <4ek1qb$11m0@pulp.ucs.ualberta.ca>,
- jbukczyn@gpu.srv.ualberta.ca says...
- >
- >Anyone have good source/algorithrm/ideas of how to do this
- >as fast as possible?
- >
- >please reply to jbukczyn@gpu.srv.ualberta.ca
- >
- >Thanks in advance...
- >
-
- You can use the std C libr function, "strstr" to do a brute force string
- search or you can implement the Boyer-Moore string search method for a
- 4:1 average performance increase over brute force. Boyer-moore and other
- algos can be found in various text books.
-
- There are other search algorithms as well which I am sure one of the
- readers will post.
-
- A point of fact, though... we had DB2 (IBM's industrial strength,
- mainframe-based RDBMS) a couple of years ago. SQL supported searching
- text fields for a substring. Since one might search a million records for
- a piece of text in a column (field), you might expect that DB2 would have
- implemented some super-duper string search algorithm, but it didn't. It
- used "brute force".
-
- Hope this helps some,
- Greg DiGiorgio
-
-